import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import Components from "unplugin-vue-components/vite";
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
import AutoImport from "unplugin-auto-import/vite";
import path from "path";
import tailwindcss from '@tailwindcss/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ["vue"],
      dts: "src/auto-imports.d.ts",
    }),
    Components({
      resolvers: [
        AntDesignVueResolver({
          importStyle: "less",
        }),
      ],
      dts: "src/components.d.ts",
    }),
    tailwindcss(),
  ],
  css: {
    postcss: {},
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
        modifyVars: {
          "primary-color": "#0960bd", // 主题色
        },
      },
    },
  } as any,
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
      '@/router': path.resolve(__dirname, 'src/router'), 
    },
  },
  server: {
    port: 3000, // 指定端口
  },
  build: {
    sourcemap: false, // 关闭 sourcemap 生成
  }
});